<?php


namespace app\index\controller;


use app\common\controller\UserController;
use app\common\model\EmployPurchaseOrder;
use app\common\model\ServerOrder;

class Payment extends UserController
{
    /**
     * 获取商品交易号
     */
    function pay_server_order(){
        $order_id = input("order_id");
        $order = ServerOrder::getById($order_id);
        if(empty($order)){
            $this->result_error("未找到订单");
        }
        $payment_no = \app\common\model\Payment::paymentNo();
        $order->payment_no = $payment_no;
        $order->save();
        $param["payment_no"] = $payment_no;
        $param["fee"] = $order->fee;
        $param["frozen_fee"] = $order->frozen_fee;
        $data = \app\common\model\Payment::simpleAdd($param);
        if($data){
            $this->result_success($param,0,"吊起支付");
        }else{
            $this->result_error("创建账单失败");
        }
    }

    /**
     * 获取采购支付交易号
     */
    function pay_purchase_order(){
        $order_id = input("order_id");
        $order = EmployPurchaseOrder::getById($order_id);
        if(empty($order)){
            $this->result_error("未找到订单");
        }
        $payment_no = \app\common\model\Payment::paymentNo();
        $order->payment_no = $payment_no;
        $order->save();
        $param["payment_no"] = $payment_no;
        $param["fee"] = $order->fee;
        $param["frozen_fee"] = $order->frozen_fee;
        $data = \app\common\model\Payment::simpleAdd($param);
        if($data){
            $this->result_success($param,0,"吊起支付");
        }else{
            $this->result_error("创建账单失败");
        }
    }
}